#ifndef SEA_H
#define SEA_H

#include "PlanarReflector.h"
#include "PlanarRefractor.h"
#include "PSSpray.h"

static const float epsilon = 0.000000001f;

class Sea : public PlanarReflector
{
	public:
		Sea();
		virtual ~Sea();

		void draw(int subset, ID3DX11Effect* fx, const char* technique);
		void draw(const Camera& camera, const vector<Light*>& lights);
		void init(const char* filename, ID3D11Device* g_device, ID3D11DeviceContext* g_context, int w, int h);

		void Update(float dt);
		
		void adjustSeaLevel(float daytime);

		void setDayLength(float v) { day_length = v; }

		void startFog();
		void reset();

		void drawSpray(CXMMATRIX mVP, const XMFLOAT4& pos, float dt);

		void setFrozen(bool v);
		
		void initSea11();

		bool							bSea11;

		void setRadius(float v);
		float getRadius() const { return radius; }

		void setFlag(bool v) { flag = v; }
		bool getFlag() const { return flag; }

		PlanarRefractor* getRefractor() { return mRefractor; }

		float angle;

		void setWindVector(float dir[]);

		void setWindPower(float v);

	private:
		float	m_windPower;

		PlanarRefractor*			mRefractor;
		PSSpray _spray;
		bool flag;
		bool bFog;
		float fog_start;
		float counter;
		float wave_height;
		bool bFrozen;
		float ice_percentage;
		float radius;

		ID3D11ShaderResourceView*	srv_sea0_normalmap;
		ID3D11ShaderResourceView*   srv_sea1_normalmap;

		ID3D11ShaderResourceView*	srv_ice_heightmap;
		ID3D11ShaderResourceView*	srv_ice;


		ID3DX11EffectMatrixVariable* fx_m_World;
		ID3DX11EffectMatrixVariable* fx_m_WorldViewProj;
		ID3DX11EffectMatrixVariable* fx_m_L_ViewProj;

		ID3DX11EffectShaderResourceVariable* fx_tex_shadow_map;

		ID3DX11EffectVariable*	fx_lights;

		ID3DX11EffectScalarVariable*	fx_num_lights;

		ID3DX11EffectVectorVariable*	fx_pEye;
		ID3DX11EffectScalarVariable*	fx_bShadowed;
		ID3DX11EffectScalarVariable*	fx_bUsePCSS;

		XMFLOAT3						m_windDirection;

		ID3D11Buffer*					vb_sea11;
		int								num_vertices11;

		float day_length;


};


#endif